$( function() {
	var username = $( "input[name='username']" );
	var password = $( "input[name='password']" );
	var verify = $( "input[name='verify']" );
	var flag = ""; 
	username.blur( function() {
		flag = username.val() == "" ? false : true;
		setInput( username, flag );
	} );
	password.blur( function() {
		flag = password.val() == "" ? false : true;
		setInput( password, flag );
	} );
	verify.blur( function() {
		flag = verify.val().length != 4 ? false : true;
		setInput( password, flag );
	} );
	
	$( "#login" ).submit( function() {
		if ( username.val() == "" ) {
			setInput( username, false );
			return false;
		}
		if ( password.val() == "" ) {
			setInput( password, false );
			return false;
		}
		if ( verify.val().length != 4 ) {
			setInput( verify, false );
			return false;
		}
	} );
	
	function setInput( Object, flag ) {
		if ( flag ) {
			Object.css( "border-color", "1px solid #1a4f7b" );
		} else {
			Object.css( "border-color", "#f00" );
			Object.focus();	
		}
	}
	
	// 刷新验证码
	$( "#verifyImg" ).click( function() {
		$( this ).attr( "src", $( this ).attr( "src" ) );
	} );
	
} );
